<template>
	<view class="page-arena-code">
		<uni-qrcode ref="uqrcode" cid="arena" :text="checkUrl" />
		<view class="note">
			<text>二维码有效期为五分钟，如果二维码已使用或者超过五分钟未使用，二维码将失效。若需重新获取二维码，请刷新。</text>
		</view>
		
	</view>
</template>

<script>
	import UniQrcode from '@/components/common/uni-qrcode'
	import * as arenaApi from '@/api/arena.js'
	import {baseURL} from '@/utils/config.js'
	export default {
		components: {
			UniQrcode
		},
		data() {
			return {
				id: 0,
				order_no: '',
				show: false,
				codeToken: ''
			};
		},
		computed: {
			checkUrl() {
				// return 'https://dxty.a2.enpingshi.com/code?id=730&token=f09bc5ecc669c656f1d834f395512cfe'
				return `${baseURL}/code?id=${this.id}&token=${this.codeToken}`
			}
		},
		onLoad(options) {
			this.id = options.id
			this.order_no = options.order_no
			this.show = options.refund
			console.log(options)
			this.getCodeToken()
		},
		methods: {
			
			getCodeToken() {
				arenaApi.codeToken().then(res => {
					this.codeToken = res.data.token
					console.log(this.checkUrl)
					this.$nextTick(() => {
						this.$refs.uqrcode.make()
					})
				})
			}
		}
	}
</script>

<style scoped lang="scss">
.page-arena-code{
	display: flex;
	flex-direction: column;
	align-items: center;
	padding-top: 156rpx;
	.note{
		padding: 26rpx 0rpx;
		width: 640rpx;
		margin: 0 auto;
		text-align: center;
		line-height: 1.8;
		&>text{
			padding: 0 30rpx;
		}
	}
}
</style>
